package cn.iocoder.yudao.framework.common.enums;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.LocalDateTime;
import java.util.Arrays;

/**
 * @Author: Ljx
 * @createTime: 2024年04月26日 11:19:27
 * @version: v1.0.0
 * @Description: 单据编码类型枚举
 */
@Getter
@AllArgsConstructor
public enum DocNoTypeEnum implements IntArrayValuable {

    DAY(1, "日编码"),
    MONTH(2, "月编码"),
    YEAR(3, "年编码");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DocNoTypeEnum::getType).toArray();

    /**
     * 状态值
     */
    private final Integer type;
    /**
     * 状态名
     */
    private final String name;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static String getNo(Integer status) {
        String no = "";
        if (status.equals(DAY.type)) {
            no = DateUtil.format(LocalDateTime.now(), "yyyyMMdd");
        } else if (status.equals(MONTH.type)) {
            no = DateUtil.format(LocalDateTime.now(), "yyyyMM");
        } else if (status.equals(YEAR.type)) {
            no = DateUtil.format(LocalDateTime.now(), "yyyy");
        }
        return no;
    }
}
